package com.tx.blog.user.controller;

import com.tx.blog.user.service.IUserService;
import com.tx.blog.user.vo.UserVo;
import com.tx.blog.util.HttpUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/userController")
public class UserController {
    @Autowired
    IUserService userService;

    @RequestMapping("/showUsers")
    public ModelAndView showUsers(HttpServletRequest request){
        ModelAndView mv = new ModelAndView("user/userMessage");
        String userId = HttpUtil.getCurrentUserId(request);
        UserVo userVo = userService.findUserByUserId(userId);
        mv.addObject("userVo",userVo);
        return mv;
    }
}
